<template>
  <div>
    <div class="row">
      <div class="col-md-12">
        <FrontSideTable
          v-if="currentView === STAT_DISEASE_VIEW"
          dataUrl="/decision/statDisease/getStatDiseaseList"
          addUrl="/decision/statDisease/add"
          editUrl="/decision/statDisease/edit"
          deleteUrl="/decision/statDisease/delete"
          tableTitle="统计项列表"
          searchHint="根据统计项名称查找"
          :searchProps="searchProps"
          :columns="columns"
          :form="form"
          :rules="rules"
          @beforeAdd="beforeAdd"
          @beforeEdit="beforeEdit"
          @onManage="handleManage"
          @onView="handleView"
          manageable>
          <!--表单-->
          <template slot="form">
            <el-form-item label="统计项名称" prop="name">
              <el-input v-model="form.name" placeholder="输入统计项名"></el-input>
            </el-form-item>

            <el-form-item label="统计项描述" prop="statDesc">
              <el-input v-model="form.statDesc" placeholder="输入统计项描述"></el-input>
            </el-form-item>

            <el-form-item label="检查年度" prop="inspectionYear">
              <el-date-picker v-model="form.inspectionYear" align="right" type="year" :editable="false" placeholder="选择年份"></el-date-picker>
            </el-form-item>
          </template>
        </FrontSideTable>

        <StatDiseaseBridge
          v-if="currentView === BRIDGE_VIEW"
          :statDisease="currentStatDisease"
          @onBack="currentView = STAT_DISEASE_VIEW">
        </StatDiseaseBridge>

        <StatDiseaseDetail
          v-if="currentView === STAT_DETAIL_VIEW"
          :statDisease="currentStatDisease"
          @onBack="currentView = STAT_DISEASE_VIEW">
        </StatDiseaseDetail>

      </div>
    </div>
  </div>
</template>

<script>
  import FrontSideTable from "../../template/FrontSideTable.vue"
  import StatDiseaseBridge from "../../template/StatDiseaseBridge.vue"
  import StatDiseaseDetail from "../../template/StatDiseaseDetail.vue"
  import {doGet} from "../../../assets/js/utils/RequestUtils";

  const STAT_DISEASE_VO_URL = "/decision/statDisease/getStatDiseaseVo";

  const STAT_DISEASE_VIEW = "STAT_DISEASE_VIEW",
    BRIDGE_VIEW = "BRIDGE_VIEW",
    STAT_DETAIL_VIEW = "STAT_DETAIL_VIEW";

  export default {
    name:"StatDisease",
    data() {
      return {
        currentView:STAT_DISEASE_VIEW,
        currentStatDisease:{},
        columns:[
          {prop:"name", label:"统计项名"},
          {prop:"statDesc", label:"统计项描述", width:"500"},
          {prop:"inspectionYearStr", label:"统计检查年度"},
          {prop:"bridgeCount", label:"统计桥梁总数"}
        ],
        searchProps:["name"],
        form:{},
        rules:{
          name:[
            {required:true, message:"请输入统计项名称", trigger:"blur"}
          ],
          statDesc:[
            {required:true, message:"请输入统计项描述", trigger:"blur"}
          ],
          inspectionYear:[
            {required:true, type:"date", message:"请选择统计的检查年份", trigger:"blur"}
          ]
        },
        STAT_DETAIL_VIEW,
        BRIDGE_VIEW,
        STAT_DISEASE_VIEW
      }
    },
    methods: {
      beforeAdd() {
        this.form = {};
      },
      beforeEdit(data) {
        this.form = {...data, inspectionYear:new Date(data.inspectionYear)};
      },
      handleManage(data) {
        this.currentStatDisease = data;
        this.currentView = BRIDGE_VIEW;
      },
      handleView(data) {
        this.currentStatDisease = data;
        this.currentView = STAT_DETAIL_VIEW;
      }
    },
    components:{FrontSideTable, StatDiseaseBridge, StatDiseaseDetail}
  }
</script>



// WEBPACK FOOTER //
// StatDisease.vue?5dbdbca5
